{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading Instruments from MATLAB #"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "MATLAB 2016a supports calling into Python, such that we can open instruments and communicate with them from within MATLAB applications. This takes a little bit of work, however, due to bugs in MATLAB's Python interface. Here, we'll demonstrate using the ``open_instrument.m`` MATLAB function to open instruments from their URIs."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "  File build/bdist.linux-x86_64/egg/serial/serialposix.py, line 294, in open\n",
      "\n",
      "  File build/bdist.linux-x86_64/egg/serial/serialutil.py, line 180, in __init__\n",
      "\n",
      "  File build/bdist.linux-x86_64/egg/instruments/abstract_instruments/comm/serial_manager.py, line 64, in new_serial_connection\n",
      "\n",
      "  File build/bdist.linux-x86_64/egg/instruments/abstract_instruments/instrument.py, line 438, in open_serial\n",
      "\n",
      "  File build/bdist.linux-x86_64/egg/instruments/abstract_instruments/instrument.py, line 355, in open_from_uri\n",
      "\n",
      "  File <string>, line 1, in <module>\n",
      "Python Error: SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'\n",
      "\n"
     ]
    }
   ],
   "source": [
    "instrument = open_instrument('phasematrix.PhaseMatrixFSW0020', 'serial:/dev/ttyUSB0')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "MLegacy Kernel",
   "language": "python",
   "name": "kernel_mlegacy"
  },
  "language_info": {
   "file_extension": ".m",
   "help_links": [
    {
     "text": "MetaKernel Magics",
     "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
    }
   ],
   "mimetype": "text/x-matlab",
   "name": "matlab"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
